<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // const username = 'andy'
        const user = {
            username: '小明',
            age:18
        }
         // 1. 对象解构赋值基本使用
        // const { username,age,gender } = user
        // console.log(username);
        // console.log(age);
        // console.log(gender);

        
        // 2. 更改解构变量名（重命名）  变量名: 新变量名
        // const { username:uname,age } = user
        // console.log(uname);
        // console.log(age);

         // 3. 对象数组解构
         const obj = { name:'rose',age:20,school:'黑马'}
         function prinAge( {age,name,sex,school = '传智'} ){
            console.log(age);
            console.log(name);
            console.log(sex);
            console.log(school);
         }
         prinAge(obj)

         function prinAge2(person){
            console.log(person);
         }
         prinAge2(obj)
    </script>
</body>
</html>